import java.util.Scanner;

/**
 * Created by hansheng11 on 2019/12/3 15:56.
 */
public class 第7题_整数反转 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int num = sc.nextInt();
            System.out.println(reverse(num));
        }
    }

    public static int reverse(int x) {
        long temp = 0;
        while (x != 0) {
            int pop = x % 10;
            x /= 10;
            temp = temp * 10 + pop;
            if (temp > Integer.MAX_VALUE || temp < Integer.MIN_VALUE) {
                return 0;
            }
        }
        return (int) temp;
    }
/*
    public int reverse(int x) {
        String value = String.valueOf(x);
        StringBuilder sb = new StringBuilder();
        if (value.charAt(0) == '-') {
            sb.append("-");
        }
        for (int i = value.length() - 1; i > 0; i--) {
            sb.append(value.charAt(i));
        }
        if (value.charAt(0) != '-') {
            sb.append(value.charAt(0));
        }
        try {
            return Integer.parseInt(sb.toString());
        } catch (Exception e) {
            return 0;
        }
    }*/
}
